package exercise;

/**
 * https://leetcode.cn/problems/remove-element/submissions/
 * leetcode 刷题
 */
public class Test {
    public static int removeElement(int[] nums, int val) {
        int count = 0;
        for (int i = 0; i < nums.length; i++) {
            if(nums[i] != val){
                nums[count++] = nums[i];
            }
        }
        return count;
    }

    public static void main(String[] args) {
        int[]  nums = {0,1,2,2,3,0,4,2};
        int i = removeElement(nums, 2);
        for (int j = 0; j < i; j++) {
            System.out.print(nums[j]+",");
        }
    }
}
